package com.onpositive.notes.argumnets;

import com.onpositive.data.units.Unit;
import com.onpositive.data.units.UnitKind;
import com.onpositive.notes.model.IArgumentValidator;
import com.onpositive.units.ParsedDimension;

public class DimensionValidator implements IArgumentValidator {

	private static final long serialVersionUID = 2208393401544257703L;

	public DimensionValidator(UnitKind kind) {
		super();
		this.kind = kind;
	}
	
	UnitKind kind ;
	@Override
	public boolean validate(Object value) {
		
		if( !(value instanceof ParsedDimension ) )
			return false ;
		
		ParsedDimension pDim = (ParsedDimension) value ;
		Unit unit = pDim.getUnit();
		if( unit == null )
			return false ;
		
		UnitKind otherKind = unit.getKind();
		return otherKind == kind ;
	}

}
